﻿using ComprehensiveSystem.IServices.IServices;
using ComprehensiveSystem.Model.Entities;
using ComprehensiveSystem.Model.ViewModels.Basics;
using ComprehensiveSystem.Model.ViewModels.UI;
using Microsoft.AspNetCore.Http;
using SqlSugar;
using System.Linq.Expressions;

namespace ComprehensiveSystem.IServices
{
    public interface IPatientServices : IBaseServices<PatientEntity>
    {
        #region 重写增删改查操作===========================================================

        /// <summary>
        /// 重写异步插入方法
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        new Task<WebApiCallBack> InsertAsync(PatientEntity entity);

        /// <summary>
        /// 重写异步更新方法
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        new Task<WebApiCallBack> UpdateAsync(PatientEntity entity);

        /// <summary>
        /// 重写异步更新方法
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        new Task<WebApiCallBack> UpdateAsync(List<PatientEntity> entity);

        /// <summary>
        /// 重写删除指定ID的数据
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        new Task<WebApiCallBack> DeleteByIdAsync(object id);

        /// <summary>
        /// 重写删除指定ID的数据(伪删除)
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        Task<WebApiCallBack> DeleteMarkByIdAsync(object id);

        /// <summary>
        /// 重写删除指定ID集合的数据(批量删除)
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        new Task<WebApiCallBack> DeleteByIdsAsync(string[] ids);

        #endregion


        #region 获取缓存的所有数据==========================================================

        /// <summary>
        /// 获取缓存的所有数据
        /// </summary>
        /// <returns></returns>
        Task<List<PatientEntity>> GetCaChe();

        /// <summary>
        /// 更新Cache
        /// </summary>
        Task<List<PatientEntity>> UpdateCaChe();

        #endregion

        #region 重写根据条件查询分页数据
        /// <summary>
        ///     重写根据条件查询分页数据
        /// </summary>
        /// <param name="predicate">判断集合</param>
        /// <param name="orderByType">排序方式</param>
        /// <param name="pageIndex">当前页面索引</param>
        /// <param name="pageSize">分布大小</param>
        /// <param name="orderByExpression"></param>
        /// <param name="blUseNoLock">是否使用WITH(NOLOCK)</param>
        /// <returns></returns>
        new Task<IPageList<PatientEntity>> QueryPageAsync(
            Expression<Func<PatientEntity, bool>> predicate,
            Expression<Func<PatientEntity, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
            int pageSize = 20, bool blUseNoLock = false);
        #endregion

        #region 过滤传参生成执行where
        /// <summary>
        /// 过滤传参生成执行where
        /// </summary>
        /// <param name="Request">HttpRequest请求</param>
        /// <returns></returns>
        Expression<Func<PatientEntity, bool>> ListFilter(HttpRequest Request);


        /// <summary>
        /// 过滤传参生成执行where
        /// </summary>
        /// <param name="param">传参JSON</param>
        /// <returns></returns>
        Expression<Func<PatientEntity, bool>> ListFilter(string param);
        #endregion
    }
}
